import request from '/@/utils/request';

export function getRoleList(query: Object) {
    return request({
        url: '/api/v1/system/roles',
        method: 'get',
        params: query
    })
}
export function getRoleOptions(query: Object) {
    return request({
        url: '/api/v1/system/role/options',
        method: 'get',
        params: query
    })
}

export function getRoleParams() {
    return request({
        url: '/api/v1/system/role/getParams',
        method: 'get'
    })
}

export function getRole(id: number) {
    return request({
        url: '/api/v1/system/role/detail',
        method: 'get',
        params: {id}
    })
}


export function addRole(data: object) {
    return request({
        url: '/api/v1/system/role/add',
        method: 'post',
        data: data
    })
}

export function updateRole(data: object) {
    return request({
        url: '/api/v1/system/role/update',
        method: 'put',
        data: data
    })
}


export function deleteRole(data: object) {
    return request({
        url: '/api/v1/system/role/delete',
        method: 'delete',
        data: data
    })
}

export function dataScope(data: any) {
    return request({
        url: '/api/v1/system/role/dataScope',
        method: 'put',
        data: data
    })
}


// 根据角色ID查询部门树结构
export function roleDeptTreeSelect(roleId: number) {
    return request({
        url: '/api/v1/system/role/deptTreeSelect',
        method: 'get',
        params: {roleId}
    })
}


// 根据角色ID 获取菜单权限
export function getRoleAccesses(query: Object) {
    return request({
        url: '/api/v1/system/role/accesses',
        method: 'get',
        params: query
    })
}


